<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){		
	$plugins = $this->plugin_setting('setplugins');
	$list=$this->plugins(1);
	$pluginsnew=array();
	foreach($list as $type){
			foreach($type['list'] as $k=>$p){
				if($p['is_install'] ==1){
					$p['status']=1;
					$p['id']=$k+1;
					$pluginsnew[]=$p;
				}
			}
	}
	foreach($pluginsnew as $k=>&$pn){
		foreach($plugins as $name=>$pv){
			if($pv['status'] == 0 && $name && $pn['name'] == $name){
				$pn['status'] =0;
			}
		}
		//$pn['image']=pdo_getcolumn('core_plugins',array('name'=>$pn['name']),'image');
	}
	$return['list']=$pluginsnew;
	$htmls=array(
			'type'=>'list',
			'tabs'=>array(
				array('op'=>'list','title'=>'应用管理'),
			),
			'list'=>array('data'=>'list','tip'=>'【温馨提示】：这里可以控制【应用】菜单里面，哪些应用展示，哪些不展示！','key'=>'name','edit'=>false,'list'=>array(
				array('name'=>'title','title'=>'应用名称','type'=>'string'),
				//array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'type'),
				array('name'=>'image','title'=>'图标','type'=>'image'),
				array('name'=>'desc','title'=>'简介','type'=>'string'),
				array('name'=>'status','title'=>'状态','type'=>'switch','set'=>'set'),
			),
			),
		);
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='set'){
	$id=$_RQ['name'];
	$list=$this->plugin_setting('setplugins');
	if(!$id){
		exi('参数错误！','error');
	}
	$post=get_postdata();
	if(isset($post['status'])){
		$list[$id]['status']=intval($post['status']);
	}
	$this->plugin_setting('setplugins',$list);
	exi('操作成功！');
}